package com.estar.assistsurvy.adapter;

import java.util.ArrayList;

import com.estar.assistsurvy.R;
import com.estar.assistsurvy.entity.CetificationItem;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CetificationAdapter extends BaseAdapter {

	private LayoutInflater inflater;
	private ArrayList<CetificationItem> list;
	private String[] status;
	public CetificationAdapter(Context context, ArrayList<CetificationItem> list) {
		super();
		inflater=LayoutInflater.from(context);
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if(convertView==null){
			convertView=inflater.inflate(R.layout.listview_cetificate, null);
			holder=new ViewHolder();

			holder.ceti_pic=(ImageView) convertView.findViewById(R.id.ceti_pic);
			holder.ceti_name=(TextView) convertView.findViewById(R.id.ceti_name);
			holder.ceti_state=(TextView) convertView.findViewById(R.id.ceti_state);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}

		CetificationItem item=list.get(position);
		holder.ceti_pic.setImageResource(item.getIcon());
//		GlideUtiles.loadIntoUse(context, item.getIcon(), holder.ceti_pic);
		holder.ceti_name.setText(item.getName());
		if(status!=null){
			if(status[position].equals("0")){
				holder.ceti_state.setText("待提交");
			}else if(status[position].equals("1")){
				holder.ceti_state.setText("审核中");
			}else if(status[position].equals("2")){
				holder.ceti_state.setText("审核通过");
			}else if(status[position].equals("3")){
				holder.ceti_state.setText("审核未通过");
			}
		}else{
			holder.ceti_state.setText("");
		}

		return convertView;
	}

	private class ViewHolder{
		private ImageView ceti_pic;
		private TextView ceti_name,ceti_state;
	}

	public void setStatus(String[] status){
		this.status=status;
	}

}
